//
//  DemoDanmakuItem.m
//  基本框架
//
//  Created by runone02 on 2018/7/12.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "DemoDanmakuItem.h"
#import "DemoDanmakuItemData.h"
#import "UIImageView+CornerRadius.h"

@interface DemoDanmakuItem ()
/** */
@property (nonatomic, readonly) CGFloat avatarLength;
/** */
@property (nonatomic, strong) NSLayoutConstraint *avatarWidthConst;
/** */
@property (nonatomic, strong) NSLayoutConstraint *avatarHeightConst;



@end
@implementation DemoDanmakuItem
+ (NSString *)reuseIdentifier{
    return @"DemoItemIdentifier";
}

+ (CGFloat)itemHeight{
    return 40;
}

- (CGFloat)avatarLength{
    return 30;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
    }
    return self;
}



- (UIImageView *)avatarImageView{
    if (!_avatarImageView) {
        _avatarImageView = [[UIImageView alloc]init];
        _avatarImageView.image = IMAGE(@"tabbar_im_select");
        _avatarImageView.layer.masksToBounds = YES;
        _avatarImageView.layer.cornerRadius = 15;
        _avatarImageView.layer.borderColor = [UIColor clearColor].CGColor;
        _avatarImageView.layer.borderWidth = 0.1;

        [self addSubview:_avatarImageView];
        [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.centerY.mas_equalTo(self);
            make.left.mas_equalTo(self).with.offset(10);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(30);
        }];
    }
    return _avatarImageView;
}

- (UILabel *)descLabel{
    if (!_descLabel) {
        _descLabel = [[UILabel alloc]init];
        _descLabel.textColor = [UIColor blackColor];
        _descLabel.textAlignment = NSTextAlignmentLeft;
        _descLabel.font = TITLE_FONT(30);
        [self addSubview:_descLabel];
        [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.left.mas_equalTo(self.avatarImageView.mas_right).with.offset(5);
            make.right.mas_equalTo(self).with.offset(-10);
        }];
    }
    return _descLabel;
}

- (void)prepareForReuse{
    [super prepareForReuse];
    self.avatarImageView.image = nil;
    self.descLabel.text = nil;
}

- (void)itemWillBeDisplayedWithData:(DemoDanmakuItemData *)data{
//    self.avatarImageView.image = IMAGE(data.avatarName);
    self.descLabel.text = data.desc;
}


@end
